#!/usr/bin/env python
# encoding: utf-8
'''
Ui.MainFrame -- shortdesc

Ui.MainFrame is a description

It defines classes_and_methods

@author:     Anson Chan

@copyright:  2016 Xerland Co. Ltd. All rights reserved.

@contact:    anson_chan@xerland.com
@deffield    updated: Updated
'''
from Ui.TaskBarIcon import TaskBarIcon
import wx
class Frame(wx.Frame):
    def __init__(
            self, parent=None, id=wx.ID_ANY, title='TaskBarIcon', pos=wx.DefaultPosition,
            size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE,
            exhandlerList=[]):
        wx.Frame.__init__(self, parent, id, title, pos, size, style) 
        self.screenIm = "res/TPlus.ico" 
        self.exhandlerList = exhandlerList

        # create a welcome screen
        screen = wx.Image(self.screenIm).ConvertToBitmap()
        wx.SplashScreen(screen, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,1000, None, -1)
        wx.Yield()
       
        self.SetIcon(wx.Icon(self.screenIm, wx.BITMAP_TYPE_ICO))
        self.taskBarIcon = TaskBarIcon(self)        
       
        # bind event
        self.Bind(wx.EVT_CLOSE, self.OnClose)
    def OnHide(self, event):
        self.Hide()
        
    def OnIconfiy(self, event):
        event.Skip()
        
    def OnClose(self, event):
        if self.exhandlerList:
            for handler in self.exhandlerList:
                handler.stop()
        self.taskBarIcon.Destroy()
        self.Destroy()
        